package com.mobile.manager.controller;

import com.mobile.manager.pojo.Apk;
import com.mobile.manager.pojo.DashBoard;
import com.mobile.manager.pojo.Device;
import com.mobile.manager.service.IDashBoardService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by zhangdi on 16/9/20.
 */
@Controller
@RequestMapping("/device")
public class DashBoardController {
    @Resource
    private IDashBoardService dashBoardService;
    @RequestMapping("/getDashJson")
    @ResponseBody
    public DashBoard getChartJsonOfDash(){
        //实例化三种apk
        Apk IOSapk = new Apk();
        IOSapk.setPackage_os("IOS");

        Apk Andapk = new Apk();
        Andapk.setPackage_os("Android");

        Apk apk = new Apk();
        apk.setPackage_os("");

        //实例化三种设备
        Device IOSdevice = new Device();
        IOSdevice.setOs("IOS");

        Device Anddevice = new Device();
        Anddevice.setOs("Android");

        Device device = new Device();
        device.setOs("");

        DashBoard dashBoard =new DashBoard();


        String iosapkcount = this.dashBoardService.getCountofAPKByOS(IOSapk);
        String androidcount = this.dashBoardService.getCountofAPKByOS(Andapk);
        String allcount = this.dashBoardService.getCountofAPKByOS(apk);

        String iosdevicecount = this.dashBoardService.getCountofDeviceByOS(IOSdevice);
        String anddevicecount = this.dashBoardService.getCountofDeviceByOS(Anddevice);
        String alldevicecount = this.dashBoardService.getCountofDeviceByOS(device);

        dashBoard.setCountofiosapk(Integer.valueOf(iosapkcount));
        dashBoard.setCountofallapk(Integer.valueOf(allcount));
        dashBoard.setCountofandapk(Integer.valueOf(androidcount));

        dashBoard.setCountofalldevice(Integer.valueOf(alldevicecount));
        System.out.println("anddevicecount======" + anddevicecount);
        dashBoard.setCountofanddevice(Integer.valueOf(anddevicecount));
        System.out.println("iosdevicecount======" + iosdevicecount);
        dashBoard.setCountofiosdevice(Integer.valueOf(iosdevicecount));


        return dashBoard;
    }
}
